﻿#include "StdAfx.h"
#include "DBHandle.h"
#include "BtsClient.h"
#include "ConfigImpl.h"
#include "BtsDBApi.h"
#include "strutils.h"
using namespace strutils;
//#include "FileNda1.h"
#include "ProgressDlg.h"
#include "SettingMgr.h"
#include "CommHandler.h"
#include "StepFile.h"
#include "StepListHandle.h"

CDBHandle::CDBHandle(void)
	:m_pDBApi(NULL)
	,m_nInitRet(-1)
{

}

int CDBHandle::Init(CConfig* pConfig)
{
	//assert(pConfig != 0);
	if (0 == pConfig)
		return -1;


	string sUser = "";		//数据库用户名
	string sPwd = "";		//密码
	string sPort = "";		//
	string sHost  = "";	//
	string sDBname  = "";	//

	m_pConfig = pConfig;
	m_pConfig->GetProperty("user", sUser);
	m_pConfig->GetProperty("pwd", sPwd);
	m_pConfig->GetProperty("Port", sPort);
	m_pConfig->GetProperty("Host", sHost);
	m_pConfig->GetProperty("DBname", sDBname);

	m_nInitRet = BTSDBSVR::DB_Init(sHost.c_str(), sUser.c_str(), sPwd.c_str(), 
		sDBname.c_str(), FromString<int>(sPort), &m_pDBApi);
	CRLog(E_NOTICE, "初始化数据库连接%s", m_nInitRet==0 ? "成功":"失败");
	return m_nInitRet;
}

CDBHandle::~CDBHandle(void)
{
	if (m_pDBApi)
	{
		m_pDBApi->Exit();
	}
}

//int CDBHandle::OpenChlData( const BTS_DATA_CHL& chl, const stChlTestInfo& chlInfo )
//{
//	if (!m_pDBApi || 0 != m_nInitRet)
//	{
//		AfxMessageBox(_T("连接数据库失败!"));
//		return -1;
//	}
//	//CFileNda* pFile = new CFileNda();
//	string sHisPath = g_Setting->GetUserFileKeyValue("DevList", "his_data_path");
//	if (sHisPath.empty())
//	{
//		sHisPath = g_Setting->GetSysPath() + "hisData\\";
//		_mkdir(sHisPath.c_str());
//	}
//	
//	CFileNda daFile;
//	CString strDaFileName;
//	strDaFileName.Format(_T("%d_%d_%dTD"),  chl.unit_id, chl.chl_id, chlInfo.batch);
//	//CString strTime = CStepListHandle::FormatUnixTime(task.tStartTime, 3);
//	//获取应该所在的文件夹名称
//
//	//CString strFileName = g_FileMgr->GetFileName(strTime, task.chl, task.chlInfo.batch, task.chlInfo.batcode);
//	//CString strTmpFileName = strFileName + CA2W(BTSDA_FILE_TMP.c_str());
//	CString strFold = CA2W(sHisPath.c_str());
//	
//	strFold += strDaFileName;
//	int nTail = 2;
//
//	string sPreName = CW2A(strFold);
//	string sFileName = sPreName + BTSDA_FILE_EXTENSION;
//	string sAdd;
//	while (_access(sFileName.c_str(), 0) != -1)
//	{		
//		CRLog(E_DEBUG, "当日已下载文件：%s", sFileName.c_str());
//		if (0 == remove(sFileName.c_str()))
//		{
//			break;
//		}
//
//		CRLog(E_DEBUG, "删除已下载文件失败");
//		sAdd = ToString<int>(nTail++);
//		sFileName = sPreName + sAdd + BTSDA_FILE_EXTENSION;
//	}
//
//	CString strCreate = CA2W(sFileName.c_str());
//	if (!daFile.CreateFile(strCreate.GetBuffer(MAX_PATH)))
//	{
//		AfxMessageBox(_T("创建文件失败"));
//		CRLog(E_ERROR, "创建文件失败Path=%s", sHisPath.c_str());
//		return -1;
//	}
//
//	//设备信息
//	st_DeviceInfoVer1 devInfo;
//	memset(&devInfo, 0, sizeof(devInfo));
//	DWORD dwTestId;
//	if (!m_pDBApi->GetChlTestDevInfo(chlInfo, dwTestId, devInfo))
//	{
//		CRLog(E_ERROR, "获取测试信息失败guidPath=%s", chlInfo.guidPath);
//	}
//
//	DWORD dwMaxSeq = 0 ;
//	if (!m_pDBApi->GetDFDataMaxSeqID(&chl, dwTestId, dwMaxSeq) || 0 == dwMaxSeq)
//	{
//		CRLog(E_APPINFO, "该通道没有历史数据,testid=%d, chlNo=%d", dwTestId, chl.chl_id);
//		AfxMessageBox(_T("该通道没有历史数据"));
//		return -1;
//	}
//	//测试数据，及工步信息
//	st_TestDataVer1 testData;
//	memset(&testData, 0, sizeof(testData));
//	testData.btDevID = (BYTE)chl.unit_id;
//	testData.btSubDevID =  (BYTE)chl.unit_id;
//	testData.btChlID = (BYTE)chl.chl_id;
//	testData.nTestID = dwTestId;
//	StepFileInfo stepInfo;
//	if (m_pDBApi->GetTestDataVer1( &chlInfo, testData))
//	{
//		//testData.lowVol = stepInfo.lowVol;
//		//testData.highVol = stepInfo.highVol;
//		//testData.lowCurrent = stepInfo.lowCurrent;
//		//testData.highCurrent = stepInfo.highCurrent;
//		//testData.lowCap = stepInfo.lowCap;
//		//testData.highCap = stepInfo.highCap;
//		//testData.lowPower = stepInfo.lowPower;
//		//testData.highPower = stepInfo.highPower;
//		//testData.lowTemp = stepInfo.lowTemp;
//		//testData.highTemp = stepInfo.highTemp;
//		//testData.timeInterval = stepInfo.timeInterval;
//		//testData.volInterval = stepInfo.volInterval;
//		//testData.curInterval = stepInfo.curInterval;
//		//memcpy(testData.chCreators, stepInfo.szCreator, 15);
//	}
//	else
//	{
//		CRLog(E_ERROR, "获取工步信息失败guidStep=%s", chlInfo.guidStep);
//	}
//
//	//工步数据
//	BTS_DATA_STD bts;
//	if (!m_pDBApi->GetStepDataVer1(chl, &chlInfo, bts))
//	{
//		CRLog(E_ERROR, "获取工步数据失败guidStep=%s", chlInfo.guidStep);
//	}
//	
//
//	//通道日志
//	stChlLogData stLog;
//	memset(&stLog, 0, sizeof(stLog));
//	stLog.wLogCount = MAX_CHL_LOG_COUNT;
//	DWORD dwFrom = 0;
//	if (!m_pDBApi->GetHisLogData(chl, dwTestId, dwFrom, stLog))
//	{
//		CRLog(E_ERROR, "获取通道日志数据失败testid=%d", dwTestId);
//		//daFile.InsertTestLog(stLog);
//		//dwFrom += stLog.wLogCount;
//		//stLog.wLogCount = MAX_CHL_LOG_COUNT;
//	}
//
//	daFile.WriteNdaHead( devInfo, testData, &bts, &stLog);
//	WritePulseStep(daFile, bts, stepInfo.szGuid);
//
//	theApp.m_pProgressDlg->ShowWindow(SW_SHOW);
//	theApp.m_pProgressDlg->SetStaticText(_T("文件正在下载中......"));
//
//	//历史数据
//	stChlDfDataVer1 stDf;
//	memset(&stDf, 0, sizeof(stDf));
//	stDf.wDfCount = MAX_DF_QUERY_COUNT;
//	dwFrom = 0;
//	while (m_pDBApi->GetHisDFDataVer1(chl, dwTestId, dwFrom, stDf))
//	{
//		daFile.WriteNdaData(stDf.dfData, stDf.wDfCount);
//		dwFrom += stDf.wDfCount;
//		stDf.wDfCount = MAX_DF_QUERY_COUNT;
//		theApp.m_pProgressDlg->Progress(dwMaxSeq, dwFrom);
//	}
//
//	//daFile.WriteNdaHead( devInfo, testData, &bts, &stLog);
//	theApp.m_pProgressDlg->ShowWindow(SW_HIDE);
//	daFile.Finish();
//	CRLog(E_DEBUG, "下载完成%s", CW2A(strCreate));
//	if (_access(sFileName.c_str(), 0) == -1)
//	{
//		AfxMessageBox(_T("下载失败"));
//		return -1;
//	}
//
//	string sDaFile = g_CommHandler.GetBtsdaPath(); //读取相对路径
//#ifndef _DEBUG
//	sDaFile = GetSetting()->GetSysPath() + sDaFile;
//#endif
//
//	CString strExe = CA2W(sDaFile.c_str());
//	if (!strExe.IsEmpty())
//	{
//		//CString strFold = _T("E:\VCworkspace\TaoCode_BTS\trunk\Client\BIN_CPLUS\hisData\2_50_1_15HS.bdf");
//
//		CRLog(E_DEBUG, "使用da软件的路径%s", CW2A(strExe));
//		strCreate.Insert(0,_T("\""));
//		strCreate += _T("\"");
//		ShellExecute(NULL, _T("open"), strExe, strCreate, NULL, SW_SHOWNORMAL);
//	}
//	else
//	{
//		CRLog(E_ERROR, "未配置BTSDA软件路径");
//	}
//
//	return 0;
//}

int CDBHandle::GetChlStepInfo( StepFileInfo &stepInfo, BTS_DATA_STD &bts, const stChlTestInfo chlInfo )
{
	if (!m_pDBApi || 0 != m_nInitRet)
	{
		AfxMessageBox(_T("连接数据库失败!"));
		return -1;
	}
	BTS_DATA_CHL chl;
	//工步信息
	if (!m_pDBApi->GetStepInfoVer1(chl, &chlInfo, stepInfo))
	{
		CRLog(E_ERROR, "获取工步信息失败guidStep=%s", chlInfo.guidStep);
		return -1;
	}

	//工步数据
	if (!m_pDBApi->GetStepDataVer1(chl, &chlInfo, bts))
	{
		CRLog(E_ERROR, "获取工步数据失败guidStep=%s", chlInfo.guidStep);
		return -1;
	}

	return 0;
}

void CDBHandle::GetPeriod(vector<int>& vIdex,vector<string>& vStr)
{
	if (!m_pDBApi || 0 != m_nInitRet)
	{
		//AfxMessageBox(_T("连接数据库失败!"));
		CRLog(E_ERROR, "%s", "连接数据库失败!");
		return ;
	}
	m_pDBApi->GetPeriod(vIdex,vStr);
}

void CDBHandle::GetHisFileList(vector<stHisDataFileInfo>& v, const char* pCondition ,const int& nExitThread)
{
	if (!m_pDBApi || 0 != m_nInitRet)
	{
		//AfxMessageBox(_T("连接数据库失败!"));
		CRLog(E_ERROR, "%s", "连接数据库失败!");
		return ;
	}
	UINT nQueryCount = 0;
	BTS_DATA_TEST*	tests = 0;
	m_pDBApi->td_GetHistList(pCondition, &nQueryCount, &tests);
	if (nQueryCount > 0)
	{
		for(int i = 0; i < nQueryCount; ++i)
		{
			stHisDataFileInfo fileInfo;
			fileInfo.btsTest = tests[i];
			BTS_DATA_CHL chl;
			chl.btDevType = tests[i].btDevType;
			chl.unit_id = tests[i].unit_id;
			chl.chl_id = tests[i].chl_id;
			if (nExitThread || !m_pDBApi->td_GetHRrdCount(&chl, tests[i].test_id, &fileInfo.count))
				break;
			v.push_back(fileInfo);
			//fileInfo.btsTest.batch = tests[i].batch;
			//fileInfo.btsTest.btDevType = tests[i].btDevType;
			//fileInfo.btsTest.chl_id = tests[i].chl_id;
			//fileInfo.btsTest.startTime = tests[i].startTime;
			//fileInfo.btsTest.test_id = tests[i].test_id;
			//fileInfo.btsTest.unit_id = tests[i].unit_id;
		}

		m_pDBApi->td_ReleaseTest(tests);
	}
}

int CDBHandle::GetRecord( stChlDfDataVer1& stDf, const char* pCondition, DWORD nStart , int nDevId)
{
	if (!m_pDBApi || 0 != m_nInitRet)
	{
		AfxMessageBox(_T("连接数据库失败!"));
		return -1;
	}
	return m_pDBApi->GetHisRecord(stDf, pCondition, nStart, nDevId);
}

BOOL CDBHandle::DelHisRecord(const char* pCondition,int nDevId)
{
	if (!m_pDBApi || 0 != m_nInitRet)
	{
		AfxMessageBox(_T("连接数据库失败!"));
		return FALSE;
	}
	return m_pDBApi->DelHisRecord(pCondition,nDevId);
}

int CDBHandle::GetHisLog( stChlLogData& stLog, const char* pCondition, int nDevId )
{
	if (!m_pDBApi || 0 != m_nInitRet)
	{
		AfxMessageBox(_T("连接数据库失败!"));
		return -1;
	}
	string strSQL = pCondition;
	char sqlLimit[1024] = {0};
	sprintf_s(sqlLimit, 1024, " AND test_id IN (SELECT testID FROM chl_test_info WHERE unit_no=%d)  ORDER BY test_time ASC,record_seq ASC LIMIT %d", nDevId, stLog.wLogCount);
	strSQL += sqlLimit;
	return m_pDBApi->GetHisLog(stLog, strSQL.c_str(), nDevId);
}

BOOL CDBHandle::DelTestInfo(const char* pCondition)
{
	if (!m_pDBApi || 0 != m_nInitRet)
	{
		AfxMessageBox(_T("连接数据库失败!"));
		return FALSE;
	}
	return m_pDBApi->DelTestInfo(pCondition);
}

BOOL CDBHandle::DelHisLog(const char* pCondition,int nDevId)
{
	if (!m_pDBApi || 0 != m_nInitRet)
	{
		AfxMessageBox(_T("连接数据库失败!"));
		return FALSE;
	}
	return m_pDBApi->DelHisLog(pCondition,nDevId);
}

int CDBHandle::GetChlHisLog( stChlLogData& stLog, const stChlTestInfo& chlInfo )
{
	if (!m_pDBApi || 0 != m_nInitRet)
	{
		AfxMessageBox(_T("连接数据库失败!"));
		return -1;
	}

	char sqlLimit[1024] = {0};
	sprintf_s(sqlLimit, 1024, " WHERE channel_id=%d AND test_id IN (SELECT testID FROM chl_test_info WHERE \
		channel_id=%d and guidPath='%s') ORDER BY test_time ASC,record_seq ASC",
		chlInfo.wChlNo,chlInfo.wChlNo, chlInfo.guidPath);
	return m_pDBApi->GetHisLog(stLog, sqlLimit, 0);
}



bool CDBHandle::GetDevInfo( st_DeviceInfoVer1& devData ,TestInfo1 &t1,const stHisDataFileInfo fileData )
{
	if (!m_pDBApi || 0 != m_nInitRet)
	{
		AfxMessageBox(_T("连接数据库失败!"));
		return false;
	}
	memset(&devData, 0, sizeof(devData));
	string sCondition = " where  \0";
	CString str;
	str.Format(_T("channel_id=%d AND testID=%lld "), 
		fileData.btsTest.chl_id, fileData.btsTest.test_id);
	sCondition += CW2A((LPCTSTR)str);
	//double dStart;
	return m_pDBApi->GetChlTestDevInfo1(devData,t1, sCondition.c_str());
}

bool CDBHandle::GetStepInfo( st_TestDataVer1& testData, const stHisDataFileInfo fileData )
{
	if (!m_pDBApi || 0 != m_nInitRet)
	{
		AfxMessageBox(_T("连接数据库失败!"));
		return false;
	}
	//st_TestDataVer1 testData;
	
	testData.btDevID = (BYTE)fileData.btsTest.unit_id;
	//testData.btSubDevID =  (BYTE)fileData.btsTest.unit_id;
	testData.btChlID = (BYTE)fileData.btsTest.chl_id;
	testData.nTestID = fileData.btsTest.test_id;

	string sCondition = string(" where szGuid='") + fileData.btsTest.guidStep;
	sCondition += "'";
	//StepFileInfo stepInfo;
	//memset(&stepInfo, 0, sizeof(stepInfo));
	if (m_pDBApi->GetTestDataVer1(testData, sCondition.c_str()))
	{
		//testData.lowVol = stepInfo.lowVol;
		//testData.highVol = stepInfo.highVol;
		//testData.lowCurrent = stepInfo.lowCurrent;
		//testData.highCurrent = stepInfo.highCurrent;
		//testData.lowCap = stepInfo.lowCap;
		//testData.highCap = stepInfo.highCap;
		//testData.lowPower = stepInfo.lowPower;
		//testData.highPower = stepInfo.highPower;
		//testData.lowTemp = stepInfo.lowTemp;
		//testData.highTemp = stepInfo.highTemp;
		//testData.timeInterval = stepInfo.timeInterval;
		//testData.volInterval = stepInfo.volInterval;
		//testData.curInterval = stepInfo.curInterval;
		//memcpy(testData.chCreators, stepInfo.szCreator, 15);
	}
	else
	{
		CRLog(E_ERROR, "获取工步信息失败:%s", sCondition.c_str());
		return false;
	}

	return true;
}

bool CDBHandle::GetStepData( BTS_DATA_STD& stepInfo, const stHisDataFileInfo fileData )
{
	if (!m_pDBApi || 0 != m_nInitRet)
	{
		AfxMessageBox(_T("连接数据库失败!"));
		return false;
	}
	string sCondition = string(" where szGuid='") + fileData.btsTest.guidStep;
	sCondition += "'";

	return m_pDBApi->GetStepDataVer1(stepInfo, sCondition.c_str());
}

bool CDBHandle::GetHisDFDataVer1( const BTS_DATA_CHL& chl, DWORD dwTestID, /* [in] */ DWORD dwFrom, /* 起始位置 */ stChlDfDataVer1& stDf,
	stChlBmsDataVer1& bmsData)
{
	if (!m_pDBApi || 0 != m_nInitRet)
	{
		AfxMessageBox(_T("连接数据库失败!"));
		return false;
	}
	return m_pDBApi->GetHisDFDataVer1(chl, dwTestID, dwFrom, stDf, bmsData);
}

int CDBHandle::GetPulseInfo( Pulse_Step &stepPulse, const char* guid, int nStepNo )
{
	int maxArg = 40;
	double* pArgValue = new double[maxArg];
	if (0 ==  m_pDBApi->GetPulse(guid,nStepNo,pArgValue,maxArg))
	{
		if (maxArg > 2)
		{
			double* pArg = pArgValue;
			pArg++;//nStepNo
			stepPulse.type = *pArg++;
			stepPulse.cycleCount = *pArg++;
			int nPulseCount = *pArg++;
			for (int i = 0; i < nPulseCount; ++i)
			{
				double dV = *pArg++;
				double dT = *pArg++;
				stepPulse.mValueTime.push_back(make_pair<double,double>(dV, dT));
			}

			//return 0;
		} 
	}

	delete []pArgValue;
	return 1;
}

//void CDBHandle::WritePulseStep( CFileNda &daFile, const BTS_DATA_STD& stepData, const char* szGuid )
//{
//	for (int i = 0; i < stepData.nSize; ++i)
//	{
//		if (stepData.step[i].mode == STEP_MODE_PULSE)
//		{
//			int maxArg = 40;
//			double* pArgValue = new double[maxArg];
//			if (0 ==  m_pDBApi->GetPulse(szGuid, stepData.step[i].index, pArgValue, maxArg))
//			{
//				if (maxArg > 3)
//				{
//					daFile.WritePulse(pArgValue, maxArg);
//				} 
//			}
//
//			delete []pArgValue;
//		} 
//		
//	}
//}

void CDBHandle::GetBarInfo( stBarCode* pBarAr,int &nCount, int nDevId )
{
	m_pDBApi->GetBarInfo(pBarAr, nCount, nDevId);
}

int CDBHandle::CheckBarInfo( vector<string>& vBar, string& sBatch )
{
	int ret = m_pDBApi->GetBarInfo(vBar, sBatch);
	if (ret == 2)
		sBatch = "包含"+vBar[0]+"的"+ToString<int>(vBar.size())+"个条码重复,";

	return ret;
}

bool CDBHandle::GetChlTestDevInfo(stChlTestInfo& chlInfo, DWORD& dwTestID, st_DeviceInfoVer1& dfData)
{
	if (!m_pDBApi || 0 != m_nInitRet)
	{
		return false;
	}
	return m_pDBApi->GetChlTestDevInfo(chlInfo,dwTestID,dfData);
}


bool CDBHandle::GetChlTestDevInfo1( st_DeviceInfoVer1& devData , TestInfo1 &t1, const char* guidPath, const BTS_DATA_CHL& chl )
{
	string sCondition = " where  \0";
	sCondition += "channel_id=" + ToString<short>(chl.chl_id);
	sCondition += " AND unit_no=" + ToString<short>(chl.unit_id);
	sCondition += "  AND guidPath='";
	sCondition += guidPath;
	sCondition += "'";
	return m_pDBApi->GetChlTestDevInfo1(devData,t1,sCondition.c_str());
}

bool CDBHandle::GetStepStack( vector<int>& vSteps, const char* guidPath, const BTS_DATA_CHL& chl )
{
	bool bQ = m_pDBApi->GetStepStack(vSteps, guidPath, chl);
	return bQ;
}

int CDBHandle::Login( const char* szUser, const char* szPwd )
{
	return m_pDBApi->Login(szUser, szPwd);
}


int CDBHandle::GetAllUserName(vector<string>& userNames,vector<int>& user_Ids,vector<int>& role_Ids)
{
	return m_pDBApi->GetAllUserName(userNames,user_Ids,role_Ids);
}


int CDBHandle::GetAllRoleName(vector<string>& roleNames,vector<int>& role_Ids)
{
	return m_pDBApi->GetAllRoleName(roleNames,role_Ids);
}

string CDBHandle::GetRoleNameByID(int role_Id)
{
	return m_pDBApi->GetRoleNameByID(role_Id);
}

string CDBHandle::GetAuthority(int role_Id)
{
	return m_pDBApi->GetAuthority(role_Id);
}

BOOL CDBHandle::AddRole(string roleName,string sAut)
{
	return m_pDBApi->AddRole(roleName,sAut);
}

BOOL CDBHandle::AddUser(string userName,string password,int role_id)
{
	return m_pDBApi->AddUser(userName,password,role_id);
}

BOOL CDBHandle::DelRole(int role_Id)
{
	return m_pDBApi->DelRole(role_Id);
}

BOOL CDBHandle::DelUser(int user_Id)
{
	return m_pDBApi->DelUser(user_Id);
}


BOOL CDBHandle::SetAuthority(int role_Id, string sAut)
{
	return m_pDBApi->SetAuthority(role_Id,sAut);
}

BOOL CDBHandle::EditUser(int user_Id, string userName,string password,int role_Id)
{
	return m_pDBApi->EditUser(user_Id,userName,password,role_Id);
}

int CDBHandle::GetChlByBarcode( BTS_DATA_CHL& chl, const char* szBarcode )
{
	return m_pDBApi->GetChlByBarcode(chl, szBarcode);
}

bool CDBHandle::GetStartInfo( StartInfo* pStart, const char* szGuidPath )
{
	map<string, StartInfo>::iterator it = m_mapStartInfo.find(szGuidPath);
	if (it != m_mapStartInfo.end())
	{
		memcpy(pStart, &it->second, sizeof(StartInfo));
		return true;
	}

	string sUser = "";		//数据库用户名
	string sPwd = "";		//密码
	string sPort = "";		//
	string sHost  = "";	//
	string sDBname  = "";	//

	m_pConfig->GetProperty("user", sUser);
	m_pConfig->GetProperty("pwd", sPwd);
	m_pConfig->GetProperty("Port", sPort);
	m_pConfig->GetProperty("Host", sHost);
	m_pConfig->GetProperty("DBname", sDBname);
	CBtsDBApi* pDBApi;
	int nInitRet = BTSDBSVR::DB_Init(sHost.c_str(), sUser.c_str(), sPwd.c_str(), 
		sDBname.c_str(), FromString<int>(sPort), &pDBApi);
	if (nInitRet != 0)
		return false;

	char sql[1024] = {0};
	sprintf_s(sql, 1024, " guidPath='%s' ",szGuidPath);
	if (pDBApi->GetStartInfo(pStart, 1, sql))	//软件第二次用该连接查中文路径一定乱码，只能每次新建连接。2020-5-21
	{
		m_mapStartInfo[szGuidPath] = *pStart;
		return true;
	}
	else
		return false;
}

bool CDBHandle::GetChlTestInfo( HisChlTestInfo& t, const char* guidPath, int chlNo )
{
	return m_nInitRet == 0 && m_pDBApi->GetChlTestInfo(t, guidPath, chlNo);
}

int CDBHandle::GetDbConnectState()
{
	return m_nInitRet;
}
